import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(0)
    const aaa = ref(0)
    const test = ref(0)
    const doubleCount = computed(() => count.value * 2)
    function increment() {
      count.value++
    }

    watch(count, (value) => {
      test.value = 100 + value
      aaa.value = 10 + value
    })

    return { count, doubleCount, increment, test, aaa }
  },
  {
    persist: {
      key: 'test',
      storage: sessionStorage,
      pick: ['test', 'aaa'],
    },
  }
)
